<?php
    $this->load->helper('form');
    $this->load->helper('ajax_upload');
?>
<!DOCTYPE HTML>
<html>
<head>
    <title>Add Task</title>
    <link href="<?=base_url(); ?>assets/libs/css/start/jquery.ui.css" rel="stylesheet">
    <link href="<?=base_url(); ?>assets/libs/css/fileuploader.css" rel="stylesheet">
    <style>
        label { display: block; }
        .text { margin-bottom: 12px; padding: 0.4em; width: 95%; }
        .qq-upload-bullet { float: left; margin-right: 10px; }
        .clear { clear: both; }
    </style>
</head>

<body>
<div class="ui-dialog ui-widget ui-widget-content ui-corner-all">
    <div class="ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix">Add Task</div>
    <div class="ui-dialog-content ui-widget-content">
        <?php
            $editing = isset($edit);
            $values = array();
            foreach(array('task_name','task_estcompletion','task_priority','task_project','task_parent', 'task_description') as $val)
            {
                if($editing)
                    $values[$val] = $edit->$val;
                else
                    $values[$val] = null;
            }
            if($editing)
                echo '<p>Task created on '.date('Y-m-d h:i',$edit->task_created).' by '.$edit->task_creator.'</p>';
            $attributes = array("class" => 'text ui-widget-content ui-corner-all', 'name' => '');
            echo form_open_multipart("");
            echo form_label('Task Name','task_name');
            $attributes['name'] = 'task_name';
            $attributes['value'] = $values['task_name'];
            echo form_input($attributes);
            echo form_label('Est. Completion Date','task_estcompletion');
            $attributes['name'] = 'task_estcompletion';
            $attributes['value'] = $values['task_estcompletion'];
            echo form_input(array_merge($attributes,array('class' => 'text ui-widget-content ui-corner-all ui-datepicker-lf')));
            echo form_label('Task Priority (1: Highest  -  5: Lowest)', 'task_priority');
            echo form_dropdown('task_priority', $priority, $values['task_priority'], 'class="text"');
            echo form_label('Task Parent', 'task_parent');
            echo form_dropdown('task_parent', $parentTask, $values['task_parent'], 'class="text"');
            echo form_label('Task\'s Project', 'task_project');
            echo form_dropdown('task_project', $project, $values['task_project'],'class="text"');
            echo form_label('Task Description', 'task_description');
            $attributes['name'] = 'task_description';
            $attributes['value'] = $values['task_description'];
            echo form_textarea($attributes);            
        ?>
        <p>Attach images to this task</p>
        <div id="image-upload-form"></div>
        <?php
            echo form_submit(array("name" => "add-task", "id" => 'task-add-btn', 'value' => 'Add Task'));
            echo form_close();
        ?>
    </div>
</div>
<script src="<?=base_url(); ?>assets/libs/js/jquery.min.js"></script>
<script src="<?=base_url(); ?>assets/libs/js/jquery.ui.min.js"></script>
<script src="<?=base_url(); ?>assets/libs/js/fileuploader.js"></script>
<script>
    $(document).ready(function(){
        $("#task-add-btn").button();
        $(".ui-datepicker-lf").datepicker({ dateFormat : "yy-mm-dd" });
    });
</script>
<?php
    echo ajax_image_upload("image-upload-form", base_url().'index.php/Filetest/upload/');
?>
</body>

</html>

